package com.restfinder.rate.model;

import javax.persistence.AssociationOverride;
import javax.persistence.AssociationOverrides;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import com.restfinder.model.IEntity;
import com.restfinder.restaurant.model.Restaurant;
import com.restfinder.user.model.User;

import lombok.Getter;
import lombok.Setter;

@Entity
@Table(name="rates")
@AssociationOverrides({
	@AssociationOverride(name="pk.user", joinColumns = @JoinColumn(name="user_id")),
	@AssociationOverride(name="pk.resturant", joinColumns = @JoinColumn(name="restaurant_id"))
})
public class Rate implements IEntity {

	@EmbeddedId
	@Getter @Setter
	private RatePK pk = new RatePK();
	@Enumerated
	@Getter @Setter
	private RateValue price;
	@Enumerated
	@Getter @Setter
	private RateValue climate;
	@Enumerated
	@Getter @Setter
	private RateValue service;
	@Enumerated
	@Getter @Setter
	private RateValue food;
	
	public User getUser(){
		return this.pk.getUser();
	}
	
	public void setUser(User user){
		this.pk.setUser(user);
	}
	
	public Restaurant getRestaurant(){
		return this.pk.getRestaurant();
	}
	
	public void setRestaurant(Restaurant restaurant){
		this.pk.setRestaurant(restaurant);
	}
	
	public boolean equals(Object obj) {
		if(this == obj) return true;
		if ((obj == null) || !(obj instanceof Rate)) {
			return false;
		}
		Rate rate = (Rate) obj;
		return rate.getPk().equals(pk);	
	}

	public long getId() {
		return 0;
	}

}
